﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="menu.aspx.cs" Inherits="UI.system.page.config.menu" %>
<%@ Import Namespace="Model" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script src="/js/jquery.min.js"></script>
    <script src="/js/common.js"></script>
    <script src="/js/md5.js"></script>
    <script src="/js/swfupload.js"></script>
    <script src="/system/js/admin.js"></script>
    <script src="/system/layui/layui.js"></script>
    <link rel="stylesheet" href="/system/layui/css/layui.css">
    <link rel="stylesheet" href="/system/layui/css/global.css">
    <link rel="stylesheet" href="/system/css/iframe.css">
    <script type="text/javascript" src="/system/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" src="/system/ueditor/ueditor.all.min.js"> </script>
    <script type="text/javascript" src="/system/ueditor/lang/zh-cn/zh-cn.js"></script>
    <style>
        .name{margin-left:0px;}
        .layui-input{height:30px; line-height:30px;}
        .layui-table td, .layui-table th{padding:5px 5px}
        .layui-form-switch{margin-top:0px;}
        .title{ height:40px; font-size:24px; color:#4f8bed; font-weight:bold; float:left;}
        .upload_show,.upload_product{margin-top:2px;}
    </style>
</head>
<body>
<div style="margin: 35px; margin-top:10px; padding-bottom:35px;">
<form class="layui-form" style="padding-left:0px;">
    <div class="title">首页菜单显示设置</div>
    <table class="layui-table">
      <colgroup>
        <col width="200">
        <col width="100">
        <col width="250">
        <col width="80">
        <col>
        <col width="130">
      </colgroup>
      <thead>
        <tr>
          <th>菜单名称</th>
          <th>菜单图标</th>
          <th>跳转页面</th>
          <th>显示顺序</th>
          <th></th>
          <th>是否显示</th>
        </tr>
      </thead>
      <tbody>
        <tr column="menu1">
          <td><input type="text" value="<%=menu1[2] %>" class="layui-input name" onblur="Update_Menu(this)"/></td>
          <td>
            <div class='upload_product upload_file_o1 <%=string.IsNullOrEmpty(menu1[3])?"":"hidden" %>'><div id="upload_file_o1"></div></div>
            <div class='upload_show <%=string.IsNullOrEmpty(menu1[3])?"hidden":"" %>'>
                 <div class="img_container"><img src="<%=menu1[3] %>"/></div>
                 <div class="reupload"><a onclick="Re_Upload(this)">重传</a></div>
            </div><div style="float:left; color:red; padding-top:5px; font-size:12px; padding-left:10px;"></div>
          </td>
          <td><input type="text" value="<%=menu1[4] %>" class="layui-input path" onblur="Update_Menu(this)"/></td>
          <td><input type="text" value="<%=menu1[0] %>" class="layui-input sort" onblur="Update_Menu(this)"/></td>
          <td></td>
          <td><input type="checkbox" name="yyy" lay-skin="switch" lay-text="是|否" lay-filter="istop" class="istop" <%=menu1[1]=="1"?"checked":"" %>></td>
        </tr>
        <tr column="menu2">
          <td><input type="text" value="<%=menu2[2] %>" class="layui-input name" onblur="Update_Menu(this)"/></td>
          <td>
            <div class='upload_product upload_file_o2 <%=string.IsNullOrEmpty(menu2[3])?"":"hidden" %>'><div id="upload_file_o2"></div></div>
            <div class='upload_show <%=string.IsNullOrEmpty(menu2[3])?"hidden":"" %>'>
                 <div class="img_container"><img src="<%=menu2[3] %>"/></div>
                 <div class="reupload"><a onclick="Re_Upload(this)">重传</a></div>
            </div><div style="float:left; color:red; padding-top:5px; font-size:12px; padding-left:10px;"></div>
          </td>
          <td><input type="text" value="<%=menu2[4] %>" class="layui-input path" onblur="Update_Menu(this)"/></td>
          <td><input type="text" value="<%=menu2[0] %>" class="layui-input sort" onblur="Update_Menu(this)"/></td>
          <td></td>
          <td><input type="checkbox" name="yyy" lay-skin="switch" lay-text="是|否" lay-filter="istop" class="istop" <%=menu2[1]=="1"?"checked":"" %>></td>
        </tr>
        <tr column="menu3">
          <td><input type="text" value="<%=menu3[2] %>" class="layui-input name" onblur="Update_Menu(this)"/></td>
          <td>
            <div class='upload_product upload_file_o3 <%=string.IsNullOrEmpty(menu2[3])?"":"hidden" %>'><div id="upload_file_o3"></div></div>
            <div class='upload_show <%=string.IsNullOrEmpty(menu3[3])?"hidden":"" %>'>
                 <div class="img_container"><img src="<%=menu3[3] %>"/></div>
                 <div class="reupload"><a onclick="Re_Upload(this)">重传</a></div>
            </div><div style="float:left; color:red; padding-top:5px; font-size:12px; padding-left:10px;"></div>
          </td>
          <td><input type="text" value="<%=menu3[4] %>" class="layui-input path" onblur="Update_Menu(this)"/></td>
          <td><input type="text" value="<%=menu3[0] %>" class="layui-input sort" onblur="Update_Menu(this)"/></td>
          <td></td>
          <td><input type="checkbox" name="yyy" lay-skin="switch" lay-text="是|否" lay-filter="istop" class="istop" <%=menu3[1]=="1"?"checked":"" %>></td>
        </tr>
        <tr column="menu4">
          <td><input type="text" value="<%=menu4[2] %>" class="layui-input name" onblur="Update_Menu(this)"/></td>
          <td>
            <div class='upload_product upload_file_o4 <%=string.IsNullOrEmpty(menu4[3])?"":"hidden" %>'><div id="upload_file_o4"></div></div>
            <div class='upload_show <%=string.IsNullOrEmpty(menu4[3])?"hidden":"" %>'>
                 <div class="img_container"><img src="<%=menu4[3] %>"/></div>
                 <div class="reupload"><a onclick="Re_Upload(this)">重传</a></div>
            </div><div style="float:left; color:red; padding-top:5px; font-size:12px; padding-left:10px;"></div>
          </td>
          <td><input type="text" value="<%=menu4[4] %>" class="layui-input path" onblur="Update_Menu(this)"/></td>
          <td><input type="text" value="<%=menu4[0] %>" class="layui-input sort" onblur="Update_Menu(this)"/></td>
          <td></td>
          <td><input type="checkbox" name="yyy" lay-skin="switch" lay-text="是|否" lay-filter="istop" class="istop" <%=menu4[1]=="1"?"checked":"" %>></td>
        </tr>
        <tr column="menu5">
          <td><input type="text" value="<%=menu5[2] %>" class="layui-input name" onblur="Update_Menu(this)"/></td>
          <td>
            <div class='upload_product upload_file_o5 <%=string.IsNullOrEmpty(menu5[3])?"":"hidden" %>'><div id="upload_file_o5"></div></div>
            <div class='upload_show <%=string.IsNullOrEmpty(menu5[3])?"hidden":"" %>'>
                 <div class="img_container"><img src="<%=menu5[3] %>"/></div>
                 <div class="reupload"><a onclick="Re_Upload(this)">重传</a></div>
            </div><div style="float:left; color:red; padding-top:5px; font-size:12px; padding-left:10px;"></div>
          </td>
          <td><input type="text" value="<%=menu5[4] %>" class="layui-input path" onblur="Update_Menu(this)"/></td>
          <td><input type="text" value="<%=menu5[0] %>" class="layui-input sort" onblur="Update_Menu(this)"/></td>
          <td></td>
          <td><input type="checkbox" name="yyy" lay-skin="switch" lay-text="是|否" lay-filter="istop" class="istop" <%=menu5[1]=="1"?"checked":"" %>></td>
        </tr>
        <tr column="menu6">
          <td><input type="text" value="<%=menu6[2] %>" class="layui-input name" onblur="Update_Menu(this)"/></td>
          <td>
            <div class='upload_product upload_file_o6 <%=string.IsNullOrEmpty(menu6[3])?"":"hidden" %>'><div id="upload_file_o6"></div></div>
            <div class='upload_show <%=string.IsNullOrEmpty(menu6[3])?"hidden":"" %>'>
                 <div class="img_container"><img src="<%=menu6[3] %>"/></div>
                 <div class="reupload"><a onclick="Re_Upload(this)">重传</a></div>
            </div><div style="float:left; color:red; padding-top:5px; font-size:12px; padding-left:10px;"></div>
          </td>
          <td><input type="text" value="<%=menu6[4] %>" class="layui-input path" onblur="Update_Menu(this)"/></td>
          <td><input type="text" value="<%=menu6[0] %>" class="layui-input sort" onblur="Update_Menu(this)"/></td>
          <td></td>
          <td><input type="checkbox" name="yyy" lay-skin="switch" lay-text="是|否" lay-filter="istop" class="istop" <%=menu6[1]=="1"?"checked":"" %>></td>
        </tr>
        <tr column="menu7">
          <td><input type="text" value="<%=menu7[2] %>" class="layui-input name" onblur="Update_Menu(this)"/></td>
          <td>
            <div class='upload_product upload_file_o7 <%=string.IsNullOrEmpty(menu7[3])?"":"hidden" %>'><div id="upload_file_o7"></div></div>
            <div class='upload_show <%=string.IsNullOrEmpty(menu7[3])?"hidden":"" %>'>
                 <div class="img_container"><img src="<%=menu7[3] %>"/></div>
                 <div class="reupload"><a onclick="Re_Upload(this)">重传</a></div>
            </div><div style="float:left; color:red; padding-top:5px; font-size:12px; padding-left:10px;"></div>
          </td>
          <td><input type="text" value="<%=menu7[4] %>" class="layui-input path" onblur="Update_Menu(this)"/></td>
          <td><input type="text" value="<%=menu7[0] %>" class="layui-input sort" onblur="Update_Menu(this)"/></td>
          <td></td>
          <td><input type="checkbox" name="yyy" lay-skin="switch" lay-text="是|否" lay-filter="istop" class="istop" <%=menu7[1]=="1"?"checked":"" %>></td>
        </tr>
        <tr column="menu8">
          <td><input type="text" value="<%=menu8[2] %>" class="layui-input name" onblur="Update_Menu(this)"/></td>
          <td>
            <div class='upload_product upload_file_o8 <%=string.IsNullOrEmpty(menu8[3])?"":"hidden" %>'><div id="upload_file_o8"></div></div>
            <div class='upload_show <%=string.IsNullOrEmpty(menu8[3])?"hidden":"" %>'>
                 <div class="img_container"><img src="<%=menu8[3] %>"/></div>
                 <div class="reupload"><a onclick="Re_Upload(this)">重传</a></div>
            </div><div style="float:left; color:red; padding-top:5px; font-size:12px; padding-left:10px;"></div>
          </td>
          <td><input type="text" value="<%=menu8[4] %>" class="layui-input path" onblur="Update_Menu(this)"/></td>
          <td><input type="text" value="<%=menu8[0] %>" class="layui-input sort" onblur="Update_Menu(this)"/></td>
          <td></td>
          <td><input type="checkbox" name="yyy" lay-skin="switch" lay-text="是|否" lay-filter="istop" class="istop" <%=menu8[1]=="1"?"checked":"" %>></td>
        </tr>
        <%foreach(TagsInfo tags in tagslist){ count++ ;%>
        <tr column="tags" tagsid="<%=tags.ID %>">
          <td><input type="text" value="<%=tags.Name %>" class="layui-input name" onblur="Update_MenuTags(this)"/></td>
          <td>
            <div class='upload_product upload_file_o<%=count %> <%=string.IsNullOrEmpty(tags.MenuIcon)?"":"hidden" %>'><div id="upload_file_o<%=count %>"></div></div>
            <div class='upload_show <%=string.IsNullOrEmpty(tags.MenuIcon)?"hidden":"" %>'>
                 <div class="img_container"><img src="<%=tags.MenuIcon %>"/></div>
                 <div class="reupload"><a onclick="Re_Upload(this)">重传</a></div>
            </div><div style="float:left; color:red; padding-top:5px; font-size:12px; padding-left:10px;"></div>
          </td>
          <td></td>
          <td><input type="text" value="<%=tags.MenuSort %>" class="layui-input menusort" onblur="Update_MenuTags(this)"/></td>
          <td></td>
          <td><input type="checkbox" name="yyy" lay-skin="switch" lay-text="是|否" lay-filter="tagsistop" class="istop" <%=tags.MenuIsTop==1?"checked":"" %>></td>
        </tr>
        <% } %>
        <%
            List<CategoryInfo> parentlist=categorylist.Where(x=>x.ParentID==0).ToList();
            foreach(CategoryInfo category in parentlist){ count++ ;%>
            <tr column="category" categoryid="<%=category.ID %>">
              <td><input type="text" value="<%=category.Name %>" class="layui-input name" onblur="Update_MenuCategory(this)"/></td>
              <td>
                <div class='upload_product upload_file_o<%=count %> <%=string.IsNullOrEmpty(category.MenuIcon)?"":"hidden" %>'><div id="upload_file_o<%=count %>"></div></div>
                <div class='upload_show <%=string.IsNullOrEmpty(category.MenuIcon)?"hidden":"" %>'>
                     <div class="img_container"><img src="<%=category.MenuIcon %>"/></div>
                     <div class="reupload"><a onclick="Re_Upload(this)">重传</a></div>
                </div><div style="float:left; color:red; padding-top:5px; font-size:12px; padding-left:10px;"></div>
              </td>
              <td></td>
              <td><input type="text" value="<%=category.MenuSort %>" class="layui-input menusort" onblur="Update_MenuCategory(this)"/></td>
              <td></td>
              <td><input type="checkbox" name="yyy" lay-skin="switch" lay-text="是|否" lay-filter="categoryistop" class="istop" <%=category.MenuIsTop==1?"checked":"" %>></td>
            </tr>
            <%
            List<CategoryInfo> childlist=categorylist.Where(x=>x.ParentID==category.ID).ToList();
            foreach(CategoryInfo child in childlist){ count++ ;%>
            <tr column="category" categoryid="<%=child.ID %>">
              <td><input type="text" value="<%=child.Name %>" class="layui-input name" onblur="Update_MenuCategory(this)"/></td>
              <td>
                <div class='upload_product upload_file_o<%=count %> <%=string.IsNullOrEmpty(child.MenuIcon)?"":"hidden" %>'><div id="upload_file_o<%=count %>"></div></div>
                <div class='upload_show <%=string.IsNullOrEmpty(child.MenuIcon)?"hidden":"" %>'>
                     <div class="img_container"><img src="<%=child.MenuIcon %>"/></div>
                     <div class="reupload"><a onclick="Re_Upload(this)">重传</a></div>
                </div><div style="float:left; color:red; padding-top:5px; font-size:12px; padding-left:10px;"></div>
              </td>
              <td></td>
              <td><input type="text" value="<%=child.MenuSort %>" class="layui-input menusort" onblur="Update_MenuCategory(this)"/></td>
              <td></td>
              <td><input type="checkbox" name="yyy" lay-skin="switch" lay-text="是|否" lay-filter="categoryistop" class="istop" <%=child.MenuIsTop==1?"checked":"" %>></td>
            </tr>
        <% }} %>
      </tbody>
    </table>
</form>
</div>
<script>

    layui.use(["form", "table", "laydate"], function () {
        var $ = layui.jquery, form = layui.form, laydate = layui.laydate;
        table = layui.table;
        form.on('switch(istop)', function (data) {
            Update_Menu(this);
        });
        form.on('switch(tagsistop)', function (data) {
            Update_MenuTags(this);
        });
        form.on('switch(categoryistop)', function (data) {
            Update_MenuCategory(this);
        });
    });

    function Update_Menu(o) {
        var obj = $(o).parent().parent();
        var data = {};
        data.act = "Update_Menu";
        data.column = obj.attr("column");
        data.sort = obj.find(".sort").val();
        data.istop = obj.find(".istop").prop("checked") ? 1 : 0;
        data.name = obj.find(".name").val();
        data.path = obj.find(".path").val();
        data.icon = obj.find(".img_container img").attr("src");
        data.sign = GetSign(data.act);
        if (data.name.indexOf("&") > -1) {
            LayerBox.Error("输入内容里不能包含&字符");
            return;
        }
        Ajax.Post("/tools/Admin.ashx", data, function (r) {});
    };

    function Update_MenuTags(o) {
        var obj = $(o).parent().parent();
        var data = {};
        data.act = "Update_MenuTags";
        data.column = obj.attr("column");
        data.menusort = obj.find(".menusort").val();
        data.menuistop = obj.find(".istop").prop("checked") ? 1 : 0;
        data.name = obj.find(".name").val();
        data.tagsid = obj.attr("tagsid");
        data.menuicon = obj.find(".img_container img").attr("src");
        data.sign = GetSign(data.act);
        if (data.name.indexOf("&") > -1) {
            LayerBox.Error("输入内容里不能包含&字符");
            return;
        }
        Ajax.Post("/tools/Admin.ashx", data, function (r) { });
    };

    function Update_MenuCategory(o) {
        var obj = $(o).parent().parent();
        var data = {};
        data.act = "Update_MenuCategory";
        data.categoryid = obj.attr("categoryid");
        data.column = obj.attr("column");
        data.menusort = obj.find(".menusort").val();
        data.menuistop = obj.find(".istop").prop("checked") ? 1 : 0;
        data.name = obj.find(".name").val();
        data.menuicon = obj.find(".img_container img").attr("src");
        data.sign = GetSign(data.act);
        if (data.name.indexOf("&") > -1) {
            LayerBox.Error("输入内容里不能包含&字符");
            return;
        }
        Ajax.Post("/tools/Admin.ashx", data, function (r) { });
    };

    var count=<%=count %>;
    for(var i=1;i<=count;i++){
        eval('var upload'+i+' = new Upload_File("upload_file_o'+i+'");');
        eval('upload'+i+'.swfu.handle = "upload_file_o";');
    }
</script>
</body>
</html>
